﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using WineStore.Models;

namespace WineStore.DAL
{
    public class WineStoreInitializer : DropCreateDatabaseIfModelChanges<WineDbContext>
    {
        protected override void Seed(WineDbContext context)
        {
            var categories = new List<Category>
            {
                new Category { CategoryName = "CATAPPLE"},
                new Category { CategoryName = "COGNAC"},
                new Category { CategoryName = "VODKA MEN"},
                new Category { CategoryName = "BORDEAUX BLENDS"},
                new Category { CategoryName = "MERLOT"},
                new Category { CategoryName = "CHARDONNAY"},
                new Category { CategoryName = "BRANDY"}
            };
            categories.ForEach(c => context.Categories.Add(c));
            context.SaveChanges();

            var products = new List<Product>
            {
                new Product { CategoryId = 1, ProductName="aaaa", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="1.jpg"},
                new Product { CategoryId = 1, ProductName="aabb", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="2.jpg"},
                new Product { CategoryId = 1, ProductName="aacc", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="3.jpg"},
                new Product { CategoryId = 1, ProductName="aadd", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="4.jpg"},
                new Product { CategoryId = 1, ProductName="aaee", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="5.jpg"},
                new Product { CategoryId = 1, ProductName="bbbb", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="6.jpg"},
                new Product { CategoryId = 1, ProductName="bbaa", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="7.jpg"},
                new Product { CategoryId = 1, ProductName="bbcc", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="8.jpg"},
                new Product { CategoryId = 1, ProductName="bbgg", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="9.jpg"},
                new Product { CategoryId = 1, ProductName="bbmm", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="10.jpg"},
                new Product { CategoryId = 1, ProductName="cccc", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="11.jpg"},
                new Product { CategoryId = 1, ProductName="ccbb", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="12.jpg"},
                new Product { CategoryId = 1, ProductName="ccoo", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="13.jpg"},
                new Product { CategoryId = 1, ProductName="ccll", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="14.jpg"},
                new Product { CategoryId = 1, ProductName="cchh", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="15.jpg"},
                new Product { CategoryId = 2, ProductName="aaaa", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="1.jpg"},
                new Product { CategoryId = 2, ProductName="aabb", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="2.jpg"},
                new Product { CategoryId = 2, ProductName="aacc", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="3.jpg"},
                new Product { CategoryId = 2, ProductName="aadd", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="4.jpg"},
                new Product { CategoryId = 2, ProductName="aaee", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="5.jpg"},
                new Product { CategoryId = 2, ProductName="bbbb", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="6.jpg"},
                new Product { CategoryId = 3, ProductName="bbaa", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="7.jpg"},
                new Product { CategoryId = 3, ProductName="bbcc", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="8.jpg"},
                new Product { CategoryId = 3, ProductName="bbgg", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="9.jpg"},
                new Product { CategoryId = 3, ProductName="bbmm", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="10.jpg"},
                new Product { CategoryId = 3, ProductName="cccc", ProductPrice= 100,DateAdd=System.DateTime.Now,ProductImage="11.jpg"},
                new Product { CategoryId = 3, ProductName="ccbb", ProductPrice= 200,DateAdd=System.DateTime.Now,ProductImage="12.jpg"},
                new Product { CategoryId = 3, ProductName="ccoo", ProductPrice= 300,DateAdd=System.DateTime.Now,ProductImage="13.jpg"},
                new Product { CategoryId = 3, ProductName="ccll", ProductPrice= 400,DateAdd=System.DateTime.Now,ProductImage="14.jpg"},
                new Product { CategoryId = 3, ProductName="cchh", ProductPrice= 500,DateAdd=System.DateTime.Now,ProductImage="15.jpg"},

            };
            products.ForEach(p => context.Products.Add(p));
            context.SaveChanges();
        }
    }
}